﻿@{
    
    
    
}
    <script type="text/javascript">
        function onEdit(e) {
            $(e.form).find('#ProductVariantAttributeIDString').parent().hide();
            $(e.form).find('#ProductVariantAttributeIDString').parent().prev().hide();   
           /* $(e.form).find('#ProductAttribute').data('tDropDownList').select(function (dataItem) {

                return dataItem.Value == e.dataItem['ProductAttributeID'];
            });

            $(e.form).find('#AttributeControlType').data('tDropDownList').select(function (dataItem) {

                return dataItem.Value == e.dataItem['AttributeControlTypeID'];
            });*/
        }
    </script>

<div>
    @(Html.Telerik().Grid<Sealight.UI.WebUI.Models.ProductVariantAttributeViewModel>().Name("ResultsProduct")
             .DataKeys(keys =>
             {
                 keys.Add(o => o.ProductVariantAttributeID);               
             })
                     .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.ImageAndText).ImageHtmlAttributes(new { style = "margin-left:0" }))

.Columns(columns =>
{
    columns.Bound(o => o.ProductVariantAttributeID).Hidden();
    columns.Bound(o => o.ProductAttributeID).Hidden();
    columns.Bound(o => o.AttributeControlTypeID).Hidden();
    columns.Bound(o => o.ProductAttribute).Title("Tên thuộc tính");
    columns.Bound(o => o.TextPrompt);
    columns.Bound(o => o.IsRequired).Width(100).Title("Bắt buộc");
    columns.Bound(o => o.AttributeControlType).Width(200).Title("Control Type");
    columns.Bound(o => o.DisplayOrder).Width(50).Title("Thứ tự");

    columns.Bound(o => o.ProductVariantAttributeIDString).ClientTemplate("<a  href=\"/admin/product/ListAttributeValueForProductVariantAttribute/<#=ProductVariantAttributeIDString#>\">Xem sửa giá trị</a>").Title("").Width(150);

    columns.Command(commands =>
    {
        commands.Edit().ButtonType(GridButtonType.Text);
        commands.Delete().ButtonType(GridButtonType.Text);
    }).Width(180).Title("");

}).DataBinding(dataBinding =>
                                                            dataBinding.Ajax().Select("_ProductVariantAttributeSelectAjaxEditing", "Product", new { productVariantId = ViewData["productVariantId"] })
                        .Insert("_ProductVariantAttributeInsertAjaxEditing", "Product", new { productVariantId = ViewData["productVariantId"] })
                                .Update("_ProductVariantAttributeSaveAjaxEditing", "Product", new { productVariantId = ViewData["productVariantId"] })
                                .Delete("_ProductVariantAttributeDeleteAjaxEditing", "Product", new { productVariantId = ViewData["productVariantId"] }))
        .Scrollable(scrolling => scrolling.Enabled(true))
        .Sortable(sorting => sorting.Enabled(true))
        .Pageable(paging => paging.Enabled(true))
                        .Editable(editing => editing.Mode(GridEditMode.PopUp)).ClientEvents(events => events.OnEdit("onEdit"))
        )
</div>
